package com.example.smartcity.logic.utils

import android.app.Activity

/**
 * 管理Activity
 */
object ManageActivity : Activity(){
    // 存储Activity
    private val ActivityS = ArrayList<Activity>()

    /**
     * 添加Activity
     */
    fun addActivity(activity: Activity){
        ActivityS.add(activity)
    }

    /**
     * 删除Activity
     */
    fun removeActivity(activity: Activity){
        ActivityS.remove(activity)
    }

    /**
     * 删除所有的Activity
     */
    fun removeAllActivity(){
        for (i in ActivityS){
            if (i.isFinishing){
                // 关闭当前Activity
                i.finish()
            }
        }
        // 清空所有Activity
        ActivityS.clear()
    }
}